Post

Replies

Boosts

Views

Activity

Reply to convert tuple to swift array
I've adjusted the original answer to make it more generic and also to support the other element types on top of UInt8. extension Array {   static func from(tuple: Any, start: UnsafePointer<Element>) -> [Element] {     [Element](       UnsafeBufferPointer(         start: start,         count: MemoryLayout.size(ofValue: tuple)/MemoryLayout<Element>.size       )     )   } } var someTuple: (Double, Double, Double) = (1, 2, 3) let array: [Double] = .from(tuple: someTuple, start: &someTuple.0)
Aug ’21